package com.wm.youfangtong.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding

/**
 * author: wu-meng
 * date  : 2023/12/13
 * desc  : BaseFragment
 */
abstract class BaseFragment<T : ViewBinding> : Fragment() {

    var binding: T? = null

    protected abstract fun getViewBinding(inflater: LayoutInflater,container: ViewGroup?) : T?

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = getViewBinding(inflater, container)
        return binding?.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
        initData()
        initListener()
        observeData()
    }

    abstract fun initView()

    abstract fun initData()

    abstract fun initListener()

    abstract fun observeData()

}